package com.ruoyi.cderp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cderp.domain.CustomerSettleFeeSheet;
import com.ruoyi.cderp.service.ICustomerSettleFeeSheetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户费用单Controller
 * 
 * @author ruoyi
 * @date 2025-03-11
 */
@RestController
@RequestMapping("/system/CustomerSettleFeeSheet")
public class CustomerSettleFeeSheetController extends BaseController
{
    @Autowired
    private ICustomerSettleFeeSheetService customerSettleFeeSheetService;

    /**
     * 查询客户费用单列表
     */
    @PreAuthorize("@ss.hasPermi('system:CustomerSettleFeeSheet:list')")
    @GetMapping("/list")
    public TableDataInfo list(CustomerSettleFeeSheet customerSettleFeeSheet)
    {
        startPage();
        List<CustomerSettleFeeSheet> list = customerSettleFeeSheetService.selectCustomerSettleFeeSheetList(customerSettleFeeSheet);
        return getDataTable(list);
    }

    /**
     * 导出客户费用单列表
     */
    @PreAuthorize("@ss.hasPermi('system:CustomerSettleFeeSheet:export')")
    @Log(title = "客户费用单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CustomerSettleFeeSheet customerSettleFeeSheet)
    {
        List<CustomerSettleFeeSheet> list = customerSettleFeeSheetService.selectCustomerSettleFeeSheetList(customerSettleFeeSheet);
        ExcelUtil<CustomerSettleFeeSheet> util = new ExcelUtil<CustomerSettleFeeSheet>(CustomerSettleFeeSheet.class);
        util.exportExcel(response, list, "客户费用单数据");
    }

    /**
     * 获取客户费用单详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:CustomerSettleFeeSheet:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(customerSettleFeeSheetService.selectCustomerSettleFeeSheetById(id));
    }

    /**
     * 新增客户费用单
     */
    @PreAuthorize("@ss.hasPermi('system:CustomerSettleFeeSheet:add')")
    @Log(title = "客户费用单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustomerSettleFeeSheet customerSettleFeeSheet)
    {
        return toAjax(customerSettleFeeSheetService.insertCustomerSettleFeeSheet(customerSettleFeeSheet));
    }

    /**
     * 修改客户费用单
     */
    @PreAuthorize("@ss.hasPermi('system:CustomerSettleFeeSheet:edit')")
    @Log(title = "客户费用单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomerSettleFeeSheet customerSettleFeeSheet)
    {
        return toAjax(customerSettleFeeSheetService.updateCustomerSettleFeeSheet(customerSettleFeeSheet));
    }

    /**
     * 删除客户费用单
     */
    @PreAuthorize("@ss.hasPermi('system:CustomerSettleFeeSheet:remove')")
    @Log(title = "客户费用单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(customerSettleFeeSheetService.deleteCustomerSettleFeeSheetByIds(ids));
    }
}
